package com.whenjun.enums;

import com.alibaba.fastjson.JSON;
import com.ifootbook.util.EmptyUtil;
import com.ifootbook.util.FootBookException;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum KqStateEnum {

    quanqin("quanqin", "全勤"),
    zhengchang("zhengchang", "正常"),
    queqin("queqin", "缺勤"),
    jiaban("jiaban", "加班"),
    xiujia("xiujia", "休假"),
    chidao("chidao", "迟到"),
    zaotui("zaotui", "早退"),
    ;


    private String code;

    private String name;


    public static String getNameByCode(String code) {
        String name = null;
        for (KqStateEnum kqStateEnum : KqStateEnum.values()){
            if (kqStateEnum.getCode().equals(code)) {
                name = kqStateEnum.getName();
            }
        }
        if (EmptyUtil.isEmpty(name)) {
            throw new FootBookException("code不存在");
        }
        return name;
    }

}
